package com.hgw.poippt.controller;

import com.hgw.poippt.lcn.data.RequirementPptData;
import com.hgw.poippt.lcn.service.RequirementPptGenerate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Description:
 *
 * @author LinHuiBa-YanAn
 * @date 2023/5/29 16:29
 */
@RestController
@RequestMapping("ppt")
public class PptGenerateController {

    @GetMapping("/requirement")
    public String GenerateRequirementPpt() throws Exception {
        RequirementPptData requirementPptData = new RequirementPptData();
        requirementPptData.setRequirementName("阿里裁员百分之20需求");
        requirementPptData.setBrand("高薪程序员");
        requirementPptData.setIndustry("互联网信息行业");
        requirementPptData.setCity("杭州");
        requirementPptData.setPromotionTime("5-8月");
        requirementPptData.setTargetScenario("裁员浪潮");
        requirementPptData.setSpotCategory("展位");
        requirementPptData.setArea("1000*2000");
        requirementPptData.setActiveBudget("999999999999元");
        requirementPptData.setTargetGroup("高级精英人群");
        requirementPptData.setAllActivityUri("http://www.baidu.com");
        List<RequirementPptData.ActivityData> activityDataList = new ArrayList<>(3);
        for (int i = 0; i < 2; i++) {
            RequirementPptData.ActivityData activityData = new RequirementPptData.ActivityData();
            activityData.setId(i + 1L);
            activityData.setActivityName("阿里裁员" + i + "万人");
            activityData.setPictureUri("https://banner.linhuiba.com/Fm7KRaBWbedDA-POcEx0rhhqiBnh-linhuiba_watermark");
            activityDataList.add(activityData);
        }
        requirementPptData.setActivityList(activityDataList);
        requirementPptData.setTargetInfo("杭州/家电行业/年轻白领/高收入人群");
        List<RequirementPptData.SpotData> spotDataList = new ArrayList<>();
        requirementPptData.setSpotList(spotDataList);
        for (int i = 1; i <= 10; i++) {
            RequirementPptData.SpotData spotData = new RequirementPptData.SpotData();
            spotData.setId(1000L + i);
            spotData.setName(i + "楼展位");
            spotData.setSpotDetailUri("http://www.baidu.com");
            spotData.setPlaceId(i % 2L);
            spotData.setPlaceName((i % 2)+ "场地");
            spotData.setPlaceDetailUri("http://www.baidu.com");
            spotData.setCity("杭州市");
            spotData.setDistrict("余杭区");
            spotData.setCategory(i % 3 == 1 ? "商场" : "写字楼");
            spotData.setFloor("L" + i);
            spotData.setArea("5*3");
            spotData.setWeekdaysFlow("5.5万/日");
            spotData.setDescription("该展位位于龙湖滨江天街的侧门小中庭，适合做小型品牌快闪，车展，路演等活动。因为整个场地的格调都比较高，人流量较多。");
            spotDataList.add(spotData);
        }
        List<Long> placeIds = spotDataList.stream().map(RequirementPptData.SpotData::getPlaceId).distinct().collect(Collectors.toList());
        List<RequirementPptData.PlaceData> placeDataList = placeIds.stream().map(id -> {
            RequirementPptData.PlaceData placeData = new RequirementPptData.PlaceData();
            placeData.setId(id);
            placeData.setName("场地" + id);
            placeData.setCommercialVolume("18万方");
            placeData.setFlow("20000+");
            placeData.setCrowdQuality("18-24岁占比高、女性占比高、本科学历为主、消费水平高、已婚占比63.17%");
            placeData.setBusinessCircle("城西银泰商圈");
            placeData.setPastActivity("特斯拉车展、麦当劳卖鸡腿");
            placeData.setSurroundingBrands("KFC、耐克、老乡鸡");
            placeData.setSurroundingBrands("KFC、耐克、老乡鸡");
            placeData.setPlaceDetailUri("http://wwww.baidu.com");
            List<RequirementPptData.SpotData> childrenSpotDataList = spotDataList.stream().filter(item -> id.equals(item.getPlaceId())).collect(Collectors.toList());
            placeData.setSpotList(childrenSpotDataList);
            return placeData;
        }).collect(Collectors.toList());
        requirementPptData.setPlaceList(placeDataList);
        requirementPptData.setPlaceListMapUri("http://www.baidu.com");
        RequirementPptGenerate requirementPptGenerate = new RequirementPptGenerate(requirementPptData);
        String uri = requirementPptGenerate.generatePpt();
        return uri;
    }
}
